package problem409;

//409.最长回文子串
//https://leetcode.cn/problems/longest-palindrome/description/

import java.util.Arrays;
import java.util.Comparator;

class Solution {
    public int longestPalindrome(String s) {
        int[] hash = new int[128];
        for(char ch : s.toCharArray()) {
            hash[ch]++;
        }
        int ret = 0, flag = 0;
        for(int i = 0; i<128; i++) {
            if(hash[i]%2==1) {
                flag = 1;
                ret += hash[i]-1;
            }else {
                ret += hash[i];
            }
        }
        return ret + flag;
    }
}

